package com.newhope.eshop.common.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class CheckUtil {
    /**
     * 手机号验证
     *
     * @param str
     * @return 验证通过返回true
     */
    public static boolean isMobile(final String str) {
        Pattern p = null;
        Matcher m = null;
        boolean b = false;
        p = Pattern.compile("^[1][3,4,5,7,8][0-9]{9}$"); // 验证手机号
        m = p.matcher(str);
        b = m.matches();
        return b;
    }

    /**
     * 判断是否是6位数字短信验证码
     *
     * @param code
     * @return
     */
    public static boolean isSmCode(final String code) {
        Pattern pattern = Pattern.compile("\\d{6}");
        boolean matches = pattern.matcher("a21109").matches();
        return matches;
    }
    /*public static void main(String[] args) {
        System.out.println(CheckUtil.isMobile("15053281905")) ;
        System.out.println(CheckUtil.isMobile("15053g81905")) ;
        System.out.println(CheckUtil.isSmCode("2121"));
        System.out.println(CheckUtil.isSmCode("2121aa"));
    }*/
}
